# 1.导包（快捷键：alt + enter）
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
#创建驱动对象
driver = webdriver.Chrome()
# 3.输入网址
driver.get("http://121.43.169.97:8848/pageA.html")
# 4.页面操作:通过ID属性定位页面元素
# 4.1定位元素并输入内容
driver.find_element(by=By.ID,value="userA").send_keys("admin")
driver.find_element(by=By.ID,value="passwordA").send_keys("123456")

# 通过name属性定位页面元素
driver.find_element(by=By.NAME,value="userA").send_keys("admin")
driver.find_element(by=By.NAME,value="passwordA").send_keys("123456")


#通过class定位页面元素
driver.find_element(By.CLASS_NAME,"telA").send_keys("18611111111")
driver.find_element(By.CLASS_NAME,"dzyxA").send_keys("123@qq.com")

#通过标签名定位页面元素
driver.find_element(By.TAG_NAME,"input").send_keys("admin")

#通过超链接定位页面元素
driver.find_element(By.LINK_TEXT,"百度").click()

#通过超链接定位页面元素
driver.find_element(By.PARTIAL_LINK_TEXT,"网站").click()
#Xpath绝对路径
driver.find_element(By.XPATH,"/html/body/div/fieldset/form/p[1]/input").send_keys("admin")
driver.find_element(By.XPATH,"//p[1]/input").send_keys("admin")

# id选择器
driver.find_element(By.CSS_SELECTOR,"#userA").send_keys("admin")
# 属性选择器
driver.find_element(By.CSS_SELECTOR,"[name='passwordA']").send_keys("123456")
# 类选择器
driver.find_element(By.CSS_SELECTOR,".telA").send_keys("13012345678")
# 多个class值，通过点号连接
driver.find_element(By.CSS_SELECTOR,".emailA.dzyxA").send_keys("12345@qq.com")
# 标签选择器
driver.find_element(By.CSS_SELECTOR,"button").click()

# 5.等待2秒
time.sleep(3)
# 6.退出浏览器
driver.quit()